package com.yj.apiback.controller;

import com.yj.apiback.result.Result;
import com.yj.apiback.util.ServletUtil;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.Map;

@Controller
@RequestMapping("/home")
public class HomeController {

    //session详情
    @GetMapping("/home")
    @ResponseBody
    public Result home() {
        /*
        try {
            TimeUnit.SECONDS.sleep(5);
        }catch (InterruptedException e) {
            e.printStackTrace();
        }
        */
        /*
        int a = 0 ;
        int b = 3 / a;
        */

        Map<String, String> data = new HashMap<String, String>();
        data.put("msg", "this is home page");
        String serverName = ServletUtil.getRequest().getServerName();
        data.put("domain", serverName);
        //得到当前
        return Result.success(data);
    }
}